<?php

class XML_Manipulation{
	
	var $urlXml;
	
	function _construct($url){
		$this->urlXml = $url;
	}
	
	//lấy dữ liệu từ file xml (2 cấp)
	function GetXmlCache(){		
		//echo $this->urlXml; return;
				
		if (file_exists($this->urlXml)) {
		    //$xml = file_get_contents($urlXml);
			$xml = simplexml_load_file($this->urlXml);
		} else {
		    exit('Failed to open '.$this->urlXml);
		}		
		//var_dump($xml);
		//return;
		$arrXml = array();

		foreach($xml->ThongTin as $tt){			
			$type = (string)$tt->attributes();		

			if(!isset($arrXml[$type])){
				$arrXml[$type] = array();				
			}
			array_push($arrXml[$type],array('Ten'=>(string)$tt->Ten,
							 				'CapNhat'=>(string)$tt->CapNhat,
							 				'DuLieuLienQuan'=>(string)$tt->DuLieuLienQuan));		
		}		
		//echo (string)$needUpdate->Ngay->CKNY->Ten;
		//var_dump((string)$needUpdate->Ngay->CKNY->Ten);	
		return $arrXml;
	}	
	//thay đổi dữ liệu đã có trong xml
}

?>